#include "qe_log.h"
#include "qe_hwboot.h"



QELOG_DOMAIN("qe-hwboot");



void qe_hw_boot(qe_hwboot_dev *dev, qe_ubase addr)
{
    return dev->ops->boot(dev, addr);
}

static qe_ret qe_hwboot_ioctl(qe_dev *dev, qe_int cmd, qe_ptr args)
{
    qe_hwboot_dev *hwboot = (qe_hwboot_dev *)dev;

    switch (cmd) {
    case QE_HWBOOT_IOC_BOOT:
        qe_hw_boot(hwboot, *(qe_ubase *)args);
        return qe_ok;
    default:
        return qe_err_notsupport;
    }
}

static qe_dev_ops hwboot_ops = {
    .ioctl = qe_hwboot_ioctl,
};

qe_ret qe_hwboot_register(qe_hwboot_dev *hwb, qe_const_str name, qe_hwboot_ops *ops, void *priv)
{
    qe_dev *dev;

    dev = &hwb->dev;
    
    dev->type = QE_DEV_CHAR;
    dev->rx_indicate = QE_NULL;
    dev->tx_complete = QE_NULL;
    dev->ops = &hwboot_ops;
    dev->priv = priv;

    hwb->ops = ops;

    return qe_dev_register(dev, name, 0x0);
}